package org.nobject.common.swing;

import java.io.File;

import javax.swing.filechooser.FileFilter;

/**
 * CreateFileFilter
 *
 * @author Benson
 *
 */
public class CreateFileFilter extends  FileFilter{

	private String [] acceptNames;
	
	/**
	 * 构造函数
	 * @param acceptNames
	 * @param dir
	 */
	public CreateFileFilter(String [] acceptNames,boolean dir){
		this.acceptNames=acceptNames;
	} 
	
	/* (non-Javadoc)
	 * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
	 */
	public boolean accept(File f) {
		if(this.acceptNames==null) return true;
		if(f==null) return false;
		for (int i = 0; i < acceptNames.length; i++) {
			//if(f.getName().matches(acceptNames[i].replaceAll(".","\\\\.").replaceAll("\\*",".*"))) return true;
		}
		return true;
	}

	/* (non-Javadoc)
	 * @see javax.swing.filechooser.FileFilter#getDescription()
	 */
	public String getDescription() {
		return null;
	}

}
